import { createSSRApp } from 'vue'
import { createPinia } from 'pinia'
// import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import { createPersistedState } from 'pinia-plugin-persistedstate'
import App from './App'
import '@/utils/utils.js'


export function createApp() {
  const app = createSSRApp(App)
	const pinia = createPinia()
	// pinia.use(piniaPluginPersistedstate)
	pinia.use(
		createPersistedState({
			key: id => `__persisted__${id}`,
			storage: {
				getItem(key) {
					// 处理取数据
					return uni.getStorageSync(key)
				},
				setItem(key,value) {
					// 处理存数据
					uni.setStorageSync(key,value)
				}
			}
		})
	  )
	app.use(pinia)
  return {
    app,
  }
}
